<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<!-- <body>
    <button id="forward">前进</button>
    <button id="back">后退</button>
    <button id="go">go</button>
</body>
<script>
    //window.histroy可以省略前面的window
    var forward=document.getElementById("forward");
    var back=document.getElementById("back");
    var go=document.getElementById("go");
    back.onclick=function(){
        history.back();
    }
    forward.onclick=function(){
        history.forward();
    }
    //页面访问历史 go(负值)页面回退 go(正值)页面前进 go（0）页面刷新
    go.onclick=function(){
        history.go(0);
    }
</script> -->
<body>
    <!--历史记录-->
    <button id = "forward">前进</button>
    <button id = "back">后退</button>
    <button id = "go">页面刷新</button>
</body>
<script>
    /**
     * window.history
     * 可以省略前面的window
    */
    var back = document.getElementById("back");
    var forward = document.getElementById("forward");
    var go = document.getElementById("go");
    back.onclick = function(){
        history.back();
    }
    forward.onclick = function(){
        history.forward();
    }
    /**
     * 页面访问历史 go(负值) 页面回退
     * go(正值)  页面前进
     * go(0) 页面刷新
    */
    go.onclick = function(){
        history.go(0);
    }
</script>

</html>